<div>
  <!-- 按钮 -->
  <el-button @click="showAddCatDialog" plain type="success">添加分类</el-button>

  <!-- 表格 -->
  <el-table :data="catList" style="width: 100%">
    <!-- 树  列
     file-icon="icon icon-file"
      folder-icon="icon icon-folder"
    -->
    <el-table-tree-column
      prop="cat_name"
      label="分类名称"
      width="220"
      tree-key="cat_id"
      parent-key="cat_pid"
      level-key="cat_level"
      :indent-size="20"
    ></el-table-tree-column>
    <!-- <el-table-column prop="cat_name" label="分类名称" width="180">
    </el-table-column> -->

    <el-table-column label="是否有效" width="180">
      <template slot-scope="scope">
        {{ scope.row.cat_deleted ? '否' : '是' }}
      </template>
    </el-table-column>
    <el-table-column prop="cat_level" label="层级">
      <template slot-scope="scope">
        <span v-if="scope.row.cat_level == 0">一级</span>
        <span v-else-if="scope.row.cat_level == 1">二级</span>
        <span v-else>三级</span>
      </template>
    </el-table-column>
  </el-table>

  <!-- 第一个对话框 : 添加分类对话框 -->
  <el-dialog title="添加分类" :visible.sync="dialogAddCatVisible">
    <el-form :model="addCatForm" label-width="100px">
      <el-form-item label="分类名称">
        <el-input v-model="addCatForm.cat_name"></el-input>
      </el-form-item>
      <el-form-item label="父级名称">
        <!-- 级联选择器
        options : 级联选择器的数据
        -->
        <el-cascader
          v-model="addCatForm.cat_pid_arr"
          :props="defaultProps"
          :options="options"
          change-on-select
        ></el-cascader>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogAddCatVisible = false">取 消</el-button>
      <el-button type="primary" @click="addCat">确 定</el-button>
    </div>
  </el-dialog>
</div>
